Skip to content

[9.3] Loosen apiClient ESLint rule on Security (#252212)#252665

Merged
steliosmavro merged 2 commits into
elastic:9.3from
steliosmavro:backport/9.3/pr-252212
Feb 11, 2026
Merged

[9.3] Loosen apiClient ESLint rule on Security (#252212)#252665
steliosmavro merged 2 commits into
elastic:9.3from
steliosmavro:backport/9.3/pr-252212

Conversation

@steliosmavro
Copy link
Copy Markdown
Contributor

Backport

This will backport the following commits from main to 9.3:

Questions ?

Please refer to the Backport tool documentation

## Summary

The Security Solution team has test cases that intentionally use
`esClient` directly without `apiClient`, so enforcing the
`scout_require_api_client_in_api_test` rule on their scout tests
produces false positives. Instead of excluding Security Solution from
the rule entirely, this PR enhances the rule with a configurable
`alternativeFixtures` schema option so it can accept additional fixtures
per directory.

## Changes

- Added `alternativeFixtures` schema option to
`scout_require_api_client_in_api_test`, allowing directories to
configure additional accepted fixtures via `.eslintrc.js`
- Generalized `functionUsesApiClient` to `functionUsesFixture`,
parameterizing the fixture name so the same detection logic works for
any fixture
- Error messages are dynamic and list only the accepted fixtures for the
given configuration
- Added a Security Solution override in `.eslintrc.js` with
`alternativeFixtures: ['esClient']` so their tests accept either
`apiClient` or `esClient`
- Added unit tests for the new `alternativeFixtures` option

---------

Co-authored-by: Dzmitry Lemechko <dzmitry.lemechko@elastic.co>
(cherry picked from commit 24d327b)

# Conflicts:
#	x-pack/solutions/security/plugins/entity_store/test/scout/api/tests/dsl_translation.spec.ts
#	x-pack/solutions/security/plugins/entity_store/test/scout/api/tests/esql_translation.spec.ts
#	x-pack/solutions/security/plugins/entity_store/test/scout/api/tests/painless_translation.spec.ts
@steliosmavro steliosmavro added the backport This PR is a backport of another PR label Feb 11, 2026
@steliosmavro steliosmavro enabled auto-merge (squash) February 11, 2026 09:19
@elasticmachine
Copy link
Copy Markdown
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #53 / Endpoint plugin @ess @serverless @skipInServerlessMKI Endpoint policy response api GET /api/endpoint/policy_response "before all" hook for "should return one policy response for an id"

Metrics [docs]

✅ unchanged

@steliosmavro steliosmavro merged commit 274b58d into elastic:9.3 Feb 11, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport This PR is a backport of another PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants